<template>
	<view class="container">
		<view class="major-content">
			<u-cell-group>
				<u-cell size="large"
					:icon="loginMethod == 'accountPassword'?'http://127.0.0.1:8080' + personInfo.avatar:WechatInfo.userInfo.avatarUrl"
					:iconStyle="iconStyle" isLink></u-cell>
				<u-cell size="large" title="名字" :value="personInfo.nickName" isLink></u-cell>
				<u-cell size="large" title="性别" :value="personInfo.sex==1?'女':'男'" isLink></u-cell>
				<u-cell size="large" title="电话号码" :value="personInfo.phonenumber" isLink></u-cell>
				<u-cell size="large" title="角色" :value="personInfo.admin==false?'普通角色':'管理员'" isLink></u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script setup>
	import {
		computed,
		onMounted,
		ref
	} from "vue";
	import {
		getUserProfile
	} from "@/api/system/user"
	//判断登陆方式
	const loginMethod = uni.getStorageSync('loginMethod');
	const WechatInfo = uni.getStorageSync('weChatLoginInformation');
	// const computedImag = (() => {
	// 	if (loginMethod == 'Wechat') {
	// 		return WechatInfo.userInfo.avatarUrl
	// 	} else {
	// 		// if(loginMethod == 'accountPassword')
	// 		return 'http://127.0.0.1:8080' + personInfo.avatar
	// 	}
	// })
	const personInfo = ref({
		nickName: '',
		phonenumber: '',
		email: ''
	})
	const iconStyle = ref({
		width: '100rpx',
		height: '100rpx'
	})
	onMounted(() => {
		getUserProfile().then((res) => {
			personInfo.value = res.data
			console.log(personInfo.value, '6666')
			// personInfo.value.nickName = res.data.nickName
			// personInfo.value.phonenumber = res.data.phonenumber
			// personInfo.value.email = res.data.email
		})
	})
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}
</style>